package com.thirdsdk.baidu;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;

import java.util.HashMap;
import java.util.Map;
/**
 * 地图广播接收类
 * @author Administrator
 *
 */
public class MapReceiver extends BroadcastReceiver {
	private Handler handler;
	private int what;
	public MapReceiver(Handler handler,int what){
		this.handler = handler;
		this.what=what;
	}
	@Override
	public void onReceive(Context context, Intent intent) {
		   double lat=intent.getDoubleExtra("lat", 0);   
		   double lon=intent.getDoubleExtra("lon",0);
//		   Gps gps=GISUtil.bd09_To_Gps84(lat, lon);
//		   lat=gps.getWgLat();
//		   lon=gps.getWgLon();
		   String address = intent.getStringExtra("address");
		   String city = intent.getStringExtra("city");
		   if(city != null && !"".equals(city) && !"null".equals(city)){
		      city = city.replace("市", "");
		   }
		   Map<String,Object> map =new HashMap<>();
		   map.put("lat", lat+"");
		   map.put("lon", lon+"");
		   map.put("address", address);
		   map.put("city", city);
		   Message msg = handler.obtainMessage();
		   msg.what = what;
		   msg.obj = map;
		   handler.sendMessage(msg);
	}

}
